﻿<template>
    <div style="position:relative;padding-bottom:50px;">
        <div style="line-height:32px;background:#f8f8f9;position:absolute;top:-50px;left:0;width:100%;">
            <span style="margin-right:10px;font-weight:bold;font-size:16px;colof:#000">搜索结果</span><span style="color:#999;font-size:12px;">为您搜索到<span style="color: #6dbfff">{{pageTotal}}</span>条相关结果</span>
        </div>
        <div>
            <Table :columns="columns1" highlight-row @on-current-change="publicDetails" :data="publicCityList" height='500' :loading="load"></Table>
            <div style="margin: 10px;overflow: hidden">
                <div style="float: right;">
                    <Page :total="pageTotal"
                          :current="pageNum"
                          :page-size="pageSize"
                          @on-change="handlePage"
                          @on-page-size-change="handlePageSize"
                          show-elevator
                          show-total
                          show-sizer></Page>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import {formatDate} from '../libs/tools';
    export default {
        data() {
            return {
                value: "",
                load:true,
                columns1: [{
                        title: "环评公示",
                        key: "title"
                    },
                    {
                        width: 100,
                        align: "center",
                        title: "公示时间",
                        key: "createTime",
                        render:  (h, params) => {
                            return h('div',
                                formatDate(new Date(params.row.createTime),'yyyy-MM-dd'));/*这里的this.row能够获取当前行的数据*/
                        }
                    },
                ],
                publicCityList:[],
                pageTotal:0,
                pageNum: 1,
                pageSize: 20,
            };
        },
        computed: {
            searchName() {
                return this.$store.state.searchName;
            }
        },
        methods: {
            // 公示详情
            publicDetails(currentRow,oldCurrentRow){
                this.$store.commit('toggleHotId',currentRow.id)
                this.$router.push({name: 'PublicDetials'})
            },
            getList(){
                this.load=true;
                this.$post('/publicity/findLikePublicity',
                    {
                        Title:this.searchName,
                        PageIndex:this.pageNum-1,
                        PageSize:this.pageSize
                    }
                )
                    .then( (res) => {
                        this.publicCityList = res.publicCityList;
                        this.pageTotal = res.countNum;
                        this.load=false;
                    })
                    .catch( (error) => {
                        console.log(error);
                    });
            },
            handlePage(value) {
                this.pageNum = value
                this.getList();
            },
            handlePageSize(value) {
                this.pageSize = value
                this.getList();
            },
        },
        watch: {
            'searchName'(){
                this.getList();
            }
        },
        mounted() {
            this.getList();
        }
    };
</script>

<style scoped>

</style>
